const webpack = require("webpack")

module.exports = {
  title: "东北小麦客",
  description: "编码征程",
  dest: "public",  // 静态资源的根目录 (项目根目录下的public文件夹)
  base: "/",
  head: [
    [
      "link",
      {
        "rel": "icon",
        "href": "/favicon.ico"
      },
    ],
    //增加manifest.json 重要！！！
    ['link', { rel: 'manifest', href: '/manifest.json' }],
    // 移动栏优化
    ['meta', { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no' }],
    // 引入jquery
    ["script", {
      "language": "javascript",
      "type": "text/javascript",
      "src": "https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"
    }],
    // 引入鼠标点击脚本
    ["script", {
      "language": "javascript",
      "type": "text/javascript",
      "src": "/js/MouseClickEffect.js"
    }]
  ],  
  locales:{
    // 设置默认语言
    '/': {
      "lang": "zh-CN",
    },
  },
  theme: "reco",
  themeConfig: {    
    nav: [
      {
        "text": "主页",
        "link": "/",
        "icon": "reco-home"
      },
      {
        "text": "时间轴",
        "link": "/timeline/",
        "icon": "reco-date"
      },
      {
        "text": "那些年",
        "icon": "reco-message",
        "link": "/docs/thoseYears/"
        // "items": [
        //   {
        //     "text": "vuepress-reco",
        //     "link": "/docs/theme-reco/"
        //   }
        // ]
      },
      {
        "text": "交友会",
        "icon": "reco-message",
        "items": [
          {
            "text": "GitHub",
            "link": "https://github.com/recoluan",
            "icon": "reco-github"
          }
        ]
      }
    ],
    sidebar: {
      "/docs/thoseYears/": [
        "",
        "theme",
        // "plugin",
        // "api"
      ]
    },
    type: "blog",
    blogConfig: {
      category: {
        location: 2,
        text: "分类"
      },
      tag: {
        location: 3,
        text: "标签"
      }
    },
    friendLink: [
      {
        title: "午后南杂",
        desc: "Enjoy when you can, and endure when you must.",
        email: "1156743527@qq.com",
        link: "https://www.recoluan.com"
      },
      {
        title: "vuepress-theme-reco 主题",
        desc: "A simple and beautiful vuepress Blog & Doc theme.",
        avatar: "https://vuepress-theme-reco.recoluan.com/icon_vuepress_reco.png",
        link: "https://vuepress-theme-reco.recoluan.com"
      },
      {
        title: "宋老师",
        desc: "指路人",
        avatar: "https://upload.jianshu.io/users/upload_avatars/468490/0c343e93-4af5-480c-b9d4-983ae2d610a4.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/240/h/240",
        link: "https://github.com/songboriceboy"
      }
    ],
    logo: "/logo.png",
    search: true,
    searchMaxSuggestions: 10,
    lastUpdated: "Last Updated",
    author: "东北小麦客",
    authorAvatar: "/avatar.png",
    record: "编码征程",
    startYear: "2019"
  },
  markdown: {
    // "lineNumbers": true,
    extractHeaders: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'], // 需要提取的文章标题, 会存储在 this.$page.headers 中
  },
  plugins: [ // 插件管理列表
    ['@vuepress-reco/comments',  // valine评论插件
      {
        solution: 'valine',
        options: {
          appId: 'TaRJCwrr2bPUO0H3x9nN52WO-9Nh9j0Va',// your appId
          appKey: '3F5irr0rVUb9xFQ6Ogg9nl1r', // your appKey
        }
      }
    ],
    // [
    //   "ribbon", // 全局丝带
    //   {
    //     size: 90,     // width of the ribbon, default: 90
    //     opacity: 0.8, // opacity of the ribbon, default: 0.3
    //     zIndex: -1    // z-index property of the background, default: -1
    //   }
    // ],
    // [
    //   "dynamic-title",  // 动态标题
    //   {
    //     showIcon: "/favicon.ico",
    //     showText: "(/≧▽≦/)咦！又好了！",
    //     hideIcon: "/failure.ico",
    //     hideText: "(●—●)喔哟，崩溃啦！",
    //     recoverTime: 2000
    //   }
    // ]

    // [
    //   "cursor-effects", // 光标优化
    //   {
    //     size: 2,                    // size of the particle, default: 2
    //     shape: ['star'| 'circle'],  // shape of the particle, default: 'star'
    //     zIndex: 999999999           // z-index property of the canvas, default: 999999999
    //   }
    // ]
    // [
    //   '@vuepress-reco/rotate' // 自定义插件 3D旋转魔方
    // ],
    [
      '@vuepress-reco/bgm-player',  // 音乐插件
      {
        audios: [
          // 网络文件示例
          {
            name: '起风了',
            artist: '宋姿璇',
            url: 'http://tx.stream.kg.qq.com/shkge-btfs/b667003203f290a784aeb49e35739f7c919090bb?ftnrkey=5d05825d1ba758316ac67229c53914c4549877a725a3c6cc4f6c706d23b59c8ca3d7a684f463c17619e28f7177d6e39c664a379a703ac8adc4a38dc85a0c8f9d&vkey=32E3E97926C958F115F91B657E3C7AA96369703DF9FB0A7FBE4BA0E0646AD68A1F5DBE0F621D268F7047AD5F36E56B637C6E3217797CE8E2B4AF283E0114EF118582CF6A52CD572645379B1AAD3E27D20CD93A8D3658379A&fname=1021_6ed49de8549c7db9547e47ef83f987fc618131ae.0.m4a&fromtag=1506&sdtfrom=v1506&ugcid=41582913_1563457862_608',
            cover: 'https://y.gtimg.cn/music/photo_new/T002R500x500M000000S9Ngo4bbfeM.jpg'
          },
          // 本地文件!!!,注意编译完成后修改路径, 添加 /vuepress_v2 前缀
          {
            name: '起风了（周深）',
            artist: '周深',
            url: '/static/1.mp3',
            cover: '/static/1.jpg'
          },
        ],
      }
    ],
    [
      '@vuepress/pwa',  //  快捷应用(以添加书签方式添加应用)
      {
        serviceWorker: true,
        // updatePopup: true
      }
    ]
  ],
  // 取消打包后的预加载
  shouldPrefetch: () => {
    return false
  },
  configureWebpack: (config, isServer) => {
    if( config.mode == 'production' && !isServer){
      config.optimization["splitChunks"]["chunks"] = "all" // 重要的一步
      // config.optimization["splitChunks"]["minSize"] = 100000
      config.plugins.push(new webpack.optimize.MinChunkSizePlugin({minChunkSize: 100000}))
      // console.log('^_^:', config.optimization.splitChunks)
    }
  },
}